package core

import (
    "device-modbus/internal/biz/model"
    "fmt"
)

// SensorProtocol 所有传感器插件必须实现的核心接口
type SensorProtocol interface {
    GetType() string
    GetModel() string
    GetProtocolName() string
    BuildRequest(deviceAddr, funcCode byte, startAddr, dataLength uint16) ([]byte, error)
    ParseResponse(resp []byte) (*model.SensorData, error)
}

// ProtocolCreator 插件创建函数的统一类型
type ProtocolCreator func() SensorProtocol

// 通用错误定义
var (
    ErrorInvalidResponse = fmt.Errorf("无效的响应数据")
    ErrorInvalidParams   = fmt.Errorf("无效的请求参数")
    ErrorUnsupported     = fmt.Errorf("不支持的操作")
)
